home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form ColorForm
- Appearance = 0 'Flat
- Caption = "Color"
- ClientHeight = 5820
- ClientLeft = 900
- ClientTop = 645
- ClientWidth = 7455
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- ForeColor = &H80000008&
- Height = 6510
- KeyPreview = -1 'True
- Left = 840
- LinkTopic = "Form1"
- ScaleHeight = 5820
- ScaleWidth = 7455
- Top = 15
- Width = 7575
- Begin VB.TextBox IirText
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 480
- TabIndex = 44
- Text = "255"
- Top = 3600
- Width = 855
- End
- Begin VB.TextBox IigText
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 480
- TabIndex = 43
- Text = "255"
- Top = 3960
- Width = 855
- End
- Begin VB.TextBox IibText
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 480
- TabIndex = 42
- Text = "255"
- Top = 4320
- Width = 855
- End
- Begin VB.TextBox IarText
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 480
- TabIndex = 35
- Text = "128"
- Top = 2400
- Width = 855
- End
- Begin VB.TextBox IagText
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 480
- TabIndex = 34
- Text = "128"
- Top = 2760
- Width = 855
- End
- Begin VB.TextBox IabText
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 480
- TabIndex = 33
- Text = "128"
- Top = 3120
- Width = 855
- End
- Begin VB.TextBox KabText
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 480
- TabIndex = 30
- Text = "0.30"
- Top = 1920
- Width = 855
- End
- Begin VB.TextBox KagText
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 480
- TabIndex = 27
- Text = "0.30"
- Top = 1560
- Width = 855
- End
- Begin VB.TextBox KdbText
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 480
- TabIndex = 24
- Text = "0.65"
- Top = 720
- Width = 855
- End
- Begin VB.TextBox KdgText
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 480
- TabIndex = 21
- Text = "0.65"
- Top = 360
- Width = 855
- End
- Begin VB.TextBox NText
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 480
- TabIndex = 19
- Text = "100"
- Top = 5520
- Width = 855
- End
- Begin VB.TextBox KsText
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 480
- TabIndex = 16
- Text = "5"
- Top = 5160
- Width = 855
- End
- Begin VB.TextBox KdistText
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 480
- TabIndex = 13
- Text = "-1100"
- Top = 4800
- Width = 855
- End
- Begin VB.TextBox KarText
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 480
- TabIndex = 10
- Text = "0.30"
- Top = 1200
- Width = 855
- End
- Begin VB.TextBox KdrText
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 480
- TabIndex = 8
- Text = "0.65"
- Top = 0
- Width = 855
- End
- Begin VB.TextBox PhiText
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 5400
- TabIndex = 6
- Text = "0.1571"
- Top = 5520
- Width = 855
- End
- Begin VB.TextBox ThetaText
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 3840
- TabIndex = 4
- Text = "1.8850"
- Top = 5520
- Width = 855
- End
- Begin VB.TextBox RText
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 285
- Left = 2280
- TabIndex = 2
- Text = "20.0000"
- Top = 5520
- Width = 855
- End
- Begin VB.PictureBox Pict
- AutoRedraw = -1 'True
- BackColor = &H00FFFF80&
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 5415
- Left = 1440
- Picture = "Color.frx":0000
- ScaleHeight = -14.321
- ScaleLeft = -7
- ScaleMode = 0 'User
- ScaleTop = 7
- ScaleWidth = 15.926
- TabIndex = 0
- Top = 0
- Width = 6015
- End
- Begin VB.Label Label1
- Caption = "i,r"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 31
- Left = 120
- TabIndex = 50
- Top = 3720
- Width = 375
- End
- Begin VB.Label Label1
- Caption = "I"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 30
- Left = 0
- TabIndex = 49
- Top = 3600
- Width = 135
- End
- Begin VB.Label Label1
- Caption = "I"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 29
- Left = 0
- TabIndex = 48
- Top = 3960
- Width = 135
- End
- Begin VB.Label Label1
- Caption = "i,g"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 28
- Left = 120
- TabIndex = 47
- Top = 4080
- Width = 375
- End
- Begin VB.Label Label1
- Caption = "I"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 27
- Left = 0
- TabIndex = 46
- Top = 4320
- Width = 135
- End
- Begin VB.Label Label1
- Caption = "i,b"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 26
- Left = 120
- TabIndex = 45
- Top = 4440
- Width = 375
- End
- Begin VB.Label Label1
- Caption = "a,r"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 25
- Left = 120
- TabIndex = 41
- Top = 2520
- Width = 375
- End
- Begin VB.Label Label1
- Caption = "I"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 24
- Left = 0
- TabIndex = 40
- Top = 2400
- Width = 135
- End
- Begin VB.Label Label1
- Caption = "I"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 23
- Left = 0
- TabIndex = 39
- Top = 2760
- Width = 135
- End
- Begin VB.Label Label1
- Caption = "a,g"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 22
- Left = 120
- TabIndex = 38
- Top = 2880
- Width = 375
- End
- Begin VB.Label Label1
- Caption = "I"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 21
- Left = 0
- TabIndex = 37
- Top = 3120
- Width = 135
- End
- Begin VB.Label Label1
- Caption = "a,b"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 20
- Left = 120
- TabIndex = 36
- Top = 3240
- Width = 375
- End
- Begin VB.Label Label1
- Caption = "a,b"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 19
- Left = 120
- TabIndex = 32
- Top = 2040
- Width = 375
- End
- Begin VB.Label Label1
- Caption = "k"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 18
- Left = 0
- TabIndex = 31
- Top = 1920
- Width = 135
- End
- Begin VB.Label Label1
- Caption = "a,g"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 17
- Left = 120
- TabIndex = 29
- Top = 1680
- Width = 375
- End
- Begin VB.Label Label1
- Caption = "k"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 16
- Left = 0
- TabIndex = 28
- Top = 1560
- Width = 135
- End
- Begin VB.Label Label1
- Caption = "k"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 15
- Left = 0
- TabIndex = 26
- Top = 720
- Width = 135
- End
- Begin VB.Label Label1
- Caption = "d,b"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 14
- Left = 120
- TabIndex = 25
- Top = 840
- Width = 375
- End
- Begin VB.Label Label1
- Caption = "k"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 13
- Left = 0
- TabIndex = 23
- Top = 360
- Width = 135
- End
- Begin VB.Label Label1
- Caption = "d,g"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 11
- Left = 120
- TabIndex = 22
- Top = 480
- Width = 375
- End
- Begin VB.Label Label1
- Caption = "N"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 12
- Left = 0
- TabIndex = 20
- Top = 5520
- Width = 135
- End
- Begin VB.Label Label1
- Caption = "k"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 10
- Left = 0
- TabIndex = 18
- Top = 5160
- Width = 135
- End
- Begin VB.Label Label1
- Caption = "s"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 9
- Left = 120
- TabIndex = 17
- Top = 5280
- Width = 135
- End
- Begin VB.Label Label1
- Caption = "dist"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 8
- Left = 120
- TabIndex = 15
- Top = 4920
- Width = 375
- End
- Begin VB.Label Label1
- Caption = "k"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 6
- Left = 0
- TabIndex = 14
- Top = 4800
- Width = 135
- End
- Begin VB.Label Label1
- Caption = "k"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 5
- Left = 0
- TabIndex = 12
- Top = 1200
- Width = 135
- End
- Begin VB.Label Label1
- Caption = "a,r"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 4
- Left = 120
- TabIndex = 11
- Top = 1320
- Width = 375
- End
- Begin VB.Label Label1
- Caption = "d,r"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 3
- Left = 120
- TabIndex = 9
- Top = 120
- Width = 375
- End
- Begin MSComDlg.CommonDialog LoadDialog
- Left = 6360
- Top = 5280
- _Version = 65536
- _ExtentX = 847
- _ExtentY = 847
- _StockProps = 0
- CancelError = -1 'True
- End
- Begin VB.Label Label1
- Caption = "k"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 7
- Left = 0
- TabIndex = 7
- Top = 0
- Width = 135
- End
- Begin VB.Label Label1
- Caption = "Phi"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 2
- Left = 5040
- TabIndex = 5
- Top = 5520
- Width = 375
- End
- Begin VB.Label Label1
- Caption = "Theta"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 1
- Left = 3240
- TabIndex = 3
- Top = 5520
- Width = 495
- End
- Begin VB.Label Label1
- Caption = "R"
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 700
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 255
- Index = 0
- Left = 2040
- TabIndex = 1
- Top = 5520
- Width = 255
- End
- Begin VB.Menu mnuFile
- Caption = "&File"
- Begin VB.Menu mnuFileLoad
- Caption = "&Load..."
- Shortcut = ^L
- End
- Begin VB.Menu mnuFileSaveAs
- Caption = "Save &As..."
- Shortcut = ^A
- End
- Begin VB.Menu mnuFileSep
- Caption = "-"
- End
- Begin VB.Menu mnuFileExit
- Caption = "E&xit"
- End
- End
- Attribute VB_Name = "ColorForm"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- Dim SysPalSize As Integer
- Dim NumStaticColors As Integer
- Dim StaticColor1 As Integer
- Dim StaticColor2 As Integer
- Dim syspal(0 To 255) As PALETTEENTRY
- ' Location of viewing eye.
- Dim EyeR As Single
- Dim EyeTheta As Single
- Dim EyePhi As Single
- Const dtheta = PI / 20
- Const Dphi = PI / 20
- Const dR = 1
- ' Location of focus point.
- Const FocusX = 0#
- Const FocusY = 0#
- Const FocusZ = 0#
- Dim Projector(1 To 4, 1 To 4) As Single
- Dim ThePicture As ObjPicture
- Dim ShowingParameters As Boolean
- Private Sub mnuFileSaveAs_Click()
- Dim fname As String
- Dim filenum As Integer
- ' Allow the user to pick a file.
- On Error Resume Next
- LoadDialog.filename = "*.APF"
- LoadDialog.Flags = cdlOFNOverwritePrompt + cdlOFNHideReadOnly
- LoadDialog.ShowSave
- If Err.Number = cdlCancel Then
- Unload LoadDialog
- Exit Sub
- ElseIf Err.Number <> 0 Then
- Unload LoadDialog
- Beep
- MsgBox "Error selecting file.", , vbExclamation
- Exit Sub
- End If
- On Error GoTo 0
- fname = LoadDialog.filename
- LoadDialog.InitDir = Left$(fname, Len(fname) _
- - Len(LoadDialog.FileTitle) - 1)
- ' Open the file.
- filenum = FreeFile
- Open fname For Output As #filenum
- ' Write the picture.
- ThePicture.FileWrite filenum
- ' Close the file.
- Close filenum
- End Sub
- ' *******************************************************
- ' Rotate the points in the cube and draw the cube.
- ' *******************************************************
- Private Sub DrawData(pic As Object)
- Dim old_draw As Integer
- Dim old_fill As Integer
- Dim t1(1 To 4, 1 To 4) As Single
- Dim t2(1 To 4, 1 To 4) As Single
- Dim T12(1 To 4, 1 To 4) As Single
- Dim T123(1 To 4, 1 To 4) As Single
- Dim pt As Point3D
- Dim factor As Single
- If ThePicture Is Nothing Then Exit Sub
- MousePointer = vbHourglass
- ' Get constants for the surfaces.
- LightKdr = CSng(KdrText.Text)
- LightKdg = CSng(KdgText.Text)
- LightKdb = CSng(KdbText.Text)
- LightKar = CSng(KarText.Text)
- LightKag = CSng(KagText.Text)
- LightKab = CSng(KabText.Text)
- LightKdist = CSng(KdistText.Text)
- LightKs = CSng(KsText.Text)
- LightN = CSng(NText.Text)
- ' Get the ambient light values.
- LightIar = CSng(IarText.Text)
- LightIag = CSng(IagText.Text)
- LightIab = CSng(IabText.Text)
- ' Get the incident light values.
- factor = _
- ThePicture.Distance(LightX, LightY, LightZ) _
- + LightKdist + 4
- LightIir = CSng(IirText.Text) * factor
- LightIig = CSng(IigText.Text) * factor
- LightIib = CSng(IibText.Text) * factor
- ' Prevent overflow errors when drawing lines
- ' too far out of bounds.
- On Error Resume Next
- ' Cull backfaces.
- ThePicture.Culled = False
- m3SphericalToCartesian EyeR, EyeTheta, EyePhi, EyeX, EyeY, EyeZ
- ThePicture.Cull EyeX, EyeY, EyeZ
- ' Clip faces behind the center of projection.
- ThePicture.ClipEye EyeR
- ' Transform coordinates into pixels.
- m3Scale t1, _
- Pict.ScaleX(1, Pict.ScaleMode, vbPixels), _
- Pict.ScaleY(1, Pict.ScaleMode, vbPixels), _
- 1
- m3Translate t2, _
- -Pict.ScaleX(Pict.ScaleLeft, Pict.ScaleMode, vbPixels), _
- -Pict.ScaleY(Pict.ScaleTop, Pict.ScaleMode, vbPixels), _
- 0
- m3MatMultiply T12, t1, t2
- m3MatMultiplyFull T123, Projector, T12
- ' Transform the points.
- ThePicture.ApplyFull T123
- ' Clear the screen. We must do this before
- ' selecting the pen and brush since Cls resets
- ' the pen and brush to default values.
- pic.Cls
- ' Prepare to fill polygons.
- old_draw = pic.DrawStyle
- old_fill = pic.FillStyle
- pic.DrawStyle = vbInvisible
- pic.FillStyle = vbFSSolid
- ' Display the data.
- ThePicture.DrawShaded pic, EyeR
- pic.Refresh
- ' Restore the old draw and fill styles.
- pic.DrawStyle = old_draw
- pic.FillStyle = old_fill
- ' Display the viewing parameters.
- ShowViewingParameters
- MousePointer = vbDefault
- End Sub
- Sub ShowViewingParameters()
- ShowingParameters = True
- RText.Text = Format$(EyeR, "0.0000")
- ThetaText.Text = Format$(EyeTheta, "0.0000")
- PhiText.Text = Format$(EyePhi, "0.0000")
- RText.Refresh
- ThetaText.Refresh
- PhiText.Refresh
- ShowingParameters = False
- End Sub
- Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
- Select Case KeyCode
- Case vbKeyLeft
- EyeTheta = EyeTheta - dtheta
-
- Case vbKeyRight
- EyeTheta = EyeTheta + dtheta
-
- Case vbKeyUp
- EyePhi = EyePhi - Dphi
-
- Case vbKeyDown
- EyePhi = EyePhi + Dphi
-
- Case Else
- Exit Sub
- End Select
- m3PProject Projector, m3Perspective, EyeR, EyePhi, EyeTheta, FocusX, FocusY, FocusZ, 0, 1, 0
- DrawData Pict
- End Sub
- Private Sub Form_KeyPress(KeyAscii As Integer)
- Select Case KeyAscii
- Case Asc("+")
- EyeR = EyeR + dR
-
- Case Asc("-")
- EyeR = EyeR - dR
-
- Case Else
- Exit Sub
- End Select
- m3PProject Projector, m3Perspective, EyeR, EyePhi, EyeTheta, FocusX, FocusY, FocusZ, 0, 1, 0
- DrawData Pict
- End Sub
- Private Sub Form_Load()
- ' Make sure the screen supports palettes.
- If Not GetDeviceCaps(hdc, RASTERCAPS) And RC_PALETTE Then
- Beep
- MsgBox "This monitor does not support palettes.", _
- vbCritical
- End
- End If
- ' Get system palette size and # static colors.
- SysPalSize = GetDeviceCaps(hdc, SIZEPALETTE)
- NumStaticColors = GetDeviceCaps(hdc, NUMRESERVED)
- StaticColor1 = NumStaticColors \ 2 - 1
- StaticColor2 = SysPalSize - NumStaticColors \ 2
- MatchRainbowPalette Pict
- Pict.Cls
- ' Initialize the eye position.
- EyeR = 20
- EyeTheta = PI * 0.2
- EyePhi = PI * 0.05
- ' Initialize the projection transformation.
- m3PProject Projector, m3Perspective, EyeR, EyePhi, EyeTheta, FocusX, FocusY, FocusZ, 0, 1, 0
- End Sub
- ' ***********************************************
- ' Load the control's palette so the non-static
- ' colors are shades of red, green, blue, and gray.
- ' Map the logical palette to match the system
- ' palette.
- ' Leave new system palette entries in SysPal().
- ' ***********************************************
- Sub MatchRainbowPalette(pic As Control)
- Dim origpal(0 To 255) As PALETTEENTRY
- Dim wid As Long
- Dim hgt As Long
- Dim bytes() As Byte
- Dim i As Integer
- Dim bm As BITMAP
- Dim hbm As Integer
- Dim status As Long
- Dim x As Integer
- Dim y As Integer
- Dim val As Single
- Dim dval As Single
- Dim C As Integer
- Dim clr As Integer
- Dim logpal As Long
- Dim num_each As Integer
- ' Make sure pic has the foreground palette.
- pic.ZOrder
- status = RealizePalette(pic.hdc)
- DoEvents
- ' Get the system palette entries.
- status = GetSystemPaletteEntries(pic.hdc, 0, SysPalSize, origpal(0))
-
- ' Get the image pixels.
- hbm = pic.Image
- status = GetObject(hbm, BITMAP_SIZE, bm)
- wid = bm.bmWidthBytes
- hgt = bm.bmHeight
- ReDim bytes(1 To wid, 1 To hgt)
- status = GetBitmapBits(hbm, wid * hgt, bytes(1, 1))
- ' Make the logical palette as big as possible.
- logpal = pic.Picture.hPal
- If ResizePalette(logpal, SysPalSize) = 0 Then
- Beep
- MsgBox "Error resizing logical palette.", _
- vbExclamation
- Exit Sub
- End If
- ' Blank the non-static colors.
- For i = 0 To StaticColor1
- syspal(i) = origpal(i)
- Next i
- For i = StaticColor1 + 1 To StaticColor2 - 1
- With syspal(i)
- .peRed = 0
- .peGreen = 0
- .peBlue = 0
- .peFlags = PC_NOCOLLAPSE
- End With
- Next i
- For i = StaticColor2 To 255
- syspal(i) = origpal(i)
- Next i
- status = SetPaletteEntries(logpal, 0, SysPalSize, syspal(0))
- ' Insert the non-static colors.
- num_each = (StaticColor2 - StaticColor1 - 1) / 4
- dval = 255 / (num_each - 1)
- ' Insert the reds.
- val = 0
- For i = 1 To num_each
- C = val
- val = val + dval
- With syspal(StaticColor1 + i)
- .peRed = C
- .peGreen = 0
- .peBlue = 0
- End With
- Next i
- ' Insert the greens.
- val = 0
- For i = 1 To num_each
- C = val
- val = val + dval
- With syspal(StaticColor1 + num_each + i)
- .peRed = 0
- .peGreen = C
- .peBlue = 0
- End With
- Next i
- ' Insert the blues.
- val = 0
- For i = 1 To num_each
- C = val
- val = val + dval
- With syspal(StaticColor1 + 2 * num_each + i)
- .peRed = 0
- .peGreen = 0
- .peBlue = C
- End With
- Next i
- ' Insert the grays.
- num_each = (StaticColor2 - StaticColor1 - 1) - 3 * num_each
- dval = 255 / (num_each - 1)
- val = 0
- For i = 1 To num_each
- C = val
- val = val + dval
- With syspal(StaticColor1 + 3 * num_each + i)
- .peRed = C
- .peGreen = C
- .peBlue = C
- End With
- Next i
- status = SetPaletteEntries(logpal, StaticColor1 + 1, StaticColor2 - StaticColor1 - 1, syspal(StaticColor1 + 1))
- ' Realize the new palette.
- status = RealizePalette(pic.hdc)
- pic.Refresh
- End Sub
- ' ***********************************************
- ' Load the control's palette so the non-static
- ' colors are grays. Map the logical palette to
- ' match the system palette. Convert the image to
- ' use the non-static grays.
- ' Leave new system palette entries in SysPal().
- ' ***********************************************
- Sub MatchGrayPalette(pic As Control)
- Dim origpal(0 To 255) As PALETTEENTRY
- Dim wid As Long
- Dim hgt As Long
- Dim bytes() As Byte
- Dim i As Integer
- Dim bm As BITMAP
- Dim hbm As Integer
- Dim status As Long
- Dim x As Integer
- Dim y As Integer
- Dim gray As Single
- Dim dgray As Single
- Dim C As Integer
- Dim clr As Integer
- Dim logpal As Long
- ' Make sure pic has the foreground palette.
- pic.ZOrder
- status = RealizePalette(pic.hdc)
- DoEvents
- ' Get the system palette entries.
- status = GetSystemPaletteEntries(pic.hdc, 0, SysPalSize, origpal(0))
-
- ' Get the image pixels.
- hbm = pic.Image
- status = GetObject(hbm, BITMAP_SIZE, bm)
- wid = bm.bmWidthBytes
- hgt = bm.bmHeight
- ReDim bytes(1 To wid, 1 To hgt)
- status = GetBitmapBits(hbm, wid * hgt, bytes(1, 1))
- ' Make the logical palette as big as possible.
- logpal = pic.Picture.hPal
- If ResizePalette(logpal, SysPalSize) = 0 Then
- Beep
- MsgBox "Error resizing logical palette.", _
- vbExclamation
- Exit Sub
- End If
- ' Blank the non-static colors.
- For i = 0 To StaticColor1
- syspal(i) = origpal(i)
- Next i
- For i = StaticColor1 + 1 To StaticColor2 - 1
- With syspal(i)
- .peRed = 0
- .peGreen = 0
- .peBlue = 0
- .peFlags = PC_NOCOLLAPSE
- End With
- Next i
- For i = StaticColor2 To 255
- syspal(i) = origpal(i)
- Next i
- status = SetPaletteEntries(logpal, 0, SysPalSize, syspal(0))
- ' Insert the non-static grays.
- gray = 0
- dgray = 255 / (StaticColor2 - StaticColor1 - 2)
- For i = StaticColor1 + 1 To StaticColor2 - 1
- C = gray
- gray = gray + dgray
- With syspal(i)
- .peRed = C
- .peGreen = C
- .peBlue = C
- End With
- Next i
- status = SetPaletteEntries(logpal, StaticColor1 + 1, StaticColor2 - StaticColor1 - 1, syspal(StaticColor1 + 1))
- ' Realize the gray palette.
- status = RealizePalette(pic.hdc)
- pic.Refresh
- End Sub
- Private Sub mnuFileExit_Click()
- Unload Me
- End Sub
- Private Sub mnuFileLoad_Click()
- Dim fname As String
- Dim filenum As Integer
- Dim txt As String
- Dim xmin As Single
- Dim ymin As Single
- Dim xmax As Single
- Dim ymax As Single
- ' Allow the user to pick a file.
- On Error Resume Next
- LoadDialog.filename = "*.APF"
- LoadDialog.ShowOpen
- LoadDialog.Flags = cdlOFNFileMustExist + cdlOFNHideReadOnly
- If Err.Number = cdlCancel Then
- Unload LoadDialog
- Exit Sub
- ElseIf Err.Number <> 0 Then
- Unload LoadDialog
- Beep
- MsgBox "Error selecting file.", , vbExclamation
- Exit Sub
- End If
- On Error GoTo 0
- fname = LoadDialog.filename
- LoadDialog.InitDir = Left$(fname, Len(fname) _
- - Len(LoadDialog.FileTitle) - 1)
- ' Clear the picture.
- Set ThePicture = Nothing
- ' Open the file.
- filenum = FreeFile
- Open fname For Input As #filenum
- ' Make sure it's an Object Picture File.
- Input #filenum, txt
- If txt <> "3D APF PICTURE" Then
- Close filenum
- Caption = "Color"
- Beep
- MsgBox "Error reading file """ & fname & """.", , vbExclamation
- Exit Sub
- End If
- ' Read the picture.
- Set ThePicture = New ObjPicture
- ThePicture.FileInput filenum
- ' Close the file.
- Close filenum
- Caption = "Color [" & LoadDialog.FileTitle & "]"
- ' Refresh the display.
- DrawData Pict
- End Sub
- Private Sub PhiText_Change()
- If ShowingParameters Then Exit Sub
- EyePhi = CSng(PhiText.Text)
- m3PProject Projector, m3Perspective, EyeR, EyePhi, EyeTheta, FocusX, FocusY, FocusZ, 0, 1, 0
- DrawData Pict
- End Sub
- Private Sub RText_Change()
- If ShowingParameters Then Exit Sub
- EyeR = CSng(RText.Text)
- m3PProject Projector, m3Perspective, EyeR, EyePhi, EyeTheta, FocusX, FocusY, FocusZ, 0, 1, 0
- DrawData Pict
- End Sub
- Private Sub ThetaText_Change()
- If ShowingParameters Then Exit Sub
- EyeTheta = CSng(ThetaText.Text)
- m3PProject Projector, m3Perspective, EyeR, EyePhi, EyeTheta, FocusX, FocusY, FocusZ, 0, 1, 0
- DrawData Pict
- End Sub
-